package com.nnnu.wsnackshop.controller.base;

import com.nnnu.wsnackshop.pojo.entity.Users;
import com.nnnu.wsnackshop.utils.JwtUtil;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;

@Controller
public class BaseController {


    protected Users getUser() {
        return JwtUtil.getUserFromToken((String) SecurityUtils.getSubject().getPrincipal());
    }

    protected Integer getUserId() {
        return getUser().getId();
    }


    protected Boolean isLogin() {
        return SecurityUtils.getSubject().isAuthenticated();
    }
}
